package cn.game.tanke.manger;

import cn.game.tanke.panel.TankPanel;
import cn.game.tanke.role.Enemy;

import java.util.List;

public class EnemyManager {
    private List<Enemy> enemies;

    public EnemyManager(int enemyCount, TankPanel panel) {
        // 初始化敌人列表
        enemies = new java.util.ArrayList<>();
        for (int i = 0; i < enemyCount; i++) {
            enemies.add(new Enemy(panel));
        }
    }

    public void drawEnemies(java.awt.Graphics graphics, javax.swing.JPanel jPanel) {
        for (Enemy enemy : enemies) {
            enemy.drawRole(graphics, jPanel);
        }
    }

    public List<Enemy> getEnemies() {
        return enemies;
    }

    public void stopAllEnemies() {
        for (Enemy enemy : enemies) {
            enemy.hit();
        }
    }

    public boolean areAllEnemiesDead() {
        for (Enemy enemy : enemies) {
            if (enemy.isAlive()) {
                return false;
            }
        }
        return true;
    }
}